package com.ankang.art.vo;


import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

@Data
public class Result implements Serializable {



    private Integer id;
    private Integer student_id;
    private String student_name;
    private Integer examination_id;
    private Integer result_1;
    private Integer result_2;
    private Integer result_3;
    private Integer result_4;
    private Integer result_5;
    private Integer result_6;
    private Integer result_7;
    private Integer result_8;
    private Integer result_9;
    private Integer result_10;
    private Boolean is_deleted;
    private Float avg;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getStudent_id() {
        return student_id;
    }

    public void setStudent_id(Integer student_id) {
        this.student_id = student_id;
    }

    public String getStudent_name() {
        return student_name;
    }

    public void setStudent_name(String student_name) {
        this.student_name = student_name;
    }

    public Integer getExamination_id() {
        return examination_id;
    }

    public void setExamination_id(Integer examination_id) {
        this.examination_id = examination_id;
    }

    public Integer getResult_1() {
        return result_1;
    }

    public void setResult_1(Integer result_1) {
        this.result_1 = result_1;
    }

    public Integer getResult_2() {
        return result_2;
    }

    public void setResult_2(Integer result_2) {
        this.result_2 = result_2;
    }

    public Integer getResult_3() {
        return result_3;
    }

    public void setResult_3(Integer result_3) {
        this.result_3 = result_3;
    }

    public Integer getResult_4() {
        return result_4;
    }

    public void setResult_4(Integer result_4) {
        this.result_4 = result_4;
    }

    public Integer getResult_5() {
        return result_5;
    }

    public void setResult_5(Integer result_5) {
        this.result_5 = result_5;
    }

    public Integer getResult_6() {
        return result_6;
    }

    public void setResult_6(Integer result_6) {
        this.result_6 = result_6;
    }

    public Integer getResult_7() {
        return result_7;
    }

    public void setResult_7(Integer result_7) {
        this.result_7 = result_7;
    }

    public Integer getResult_8() {
        return result_8;
    }

    public void setResult_8(Integer result_8) {
        this.result_8 = result_8;
    }

    public Integer getResult_9() {
        return result_9;
    }

    public void setResult_9(Integer result_9) {
        this.result_9 = result_9;
    }

    public Integer getResult_10() {
        return result_10;
    }

    public void setResult_10(Integer result_10) {
        this.result_10 = result_10;
    }

    public Boolean getIs_deleted() {
        return is_deleted;
    }

    public void setIs_deleted(Boolean is_deleted) {
        this.is_deleted = is_deleted;
    }

    public Float getAvg() {
        return avg;
    }

    public void setAvg(Float avg) {
        this.avg = avg;
    }

    public Integer getMax(Result result){

        List<Integer> list = new ArrayList<>();
        list.add(result.getResult_1());
        list.add(result.getResult_2());
        list.add(result.getResult_3());
        list.add(result.getResult_4());
        list.add(result.getResult_5());
        list.add(result.getResult_6());
        list.add(result.getResult_7());
        list.add(result.getResult_8());
        list.add(result.getResult_9());
        list.add(result.getResult_10());

        List<Integer> list1 =  list.stream().filter(i -> i!=0).collect(Collectors.toList());

        Integer max = list1.stream().max((x,y)->{
            if(x>y)
                return 1;
            else
                return -1;
        }).get();

        return max;

    }

    public Integer getMin(Result result){

        List<Integer> list = new ArrayList<>();
        list.add(result.getResult_1());
        list.add(result.getResult_2());
        list.add(result.getResult_3());
        list.add(result.getResult_4());
        list.add(result.getResult_5());
        list.add(result.getResult_6());
        list.add(result.getResult_7());
        list.add(result.getResult_8());
        list.add(result.getResult_9());
        list.add(result.getResult_10());

        List<Integer> list1 =  list.stream().filter(i -> i!=0).collect(Collectors.toList());

        Integer max = list1.stream().max((x,y)->{

            if(x<y)
                return 1;
            else
                return -1;
        }).get();

        return max;

    }
    public Integer getNumber(Result result){

        List<Integer> list = new ArrayList<>();
        list.add(result.getResult_1());
        list.add(result.getResult_2());
        list.add(result.getResult_3());
        list.add(result.getResult_4());
        list.add(result.getResult_5());
        list.add(result.getResult_6());
        list.add(result.getResult_7());
        list.add(result.getResult_8());
        list.add(result.getResult_9());
        list.add(result.getResult_10());



        return list.stream().reduce(Integer::sum).orElse(0);

    }
}
